package com.yiduo.outpost.support.controller;

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yiduo.outpost.support.service.UserService;
import com.yiduo.outpost.core.model.entity.User;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Author yanwen
 * @create 2023/7/25 14:39
 */
@Slf4j
@RestController
@RequestMapping("users")
@Tag(name = "UserController",description = "测试用户")
public class UserController {
    @Autowired
    private UserService userService;
    @Operation(summary = "用户列表")
    @ApiOperationSupport(author = "yiduo")
    @GetMapping("/list")
    public List<User> list() {
        log.info("list");
//
//        // 创建请求头，并设置 Content-Type 为 application/json
//        HttpHeaders headers = new HttpHeaders();
//        headers.setContentType(MediaType.APPLICATION_JSON);
//
//        // 创建包含请求体和请求头的 HttpEntity 对象
//        HttpEntity httpEntity = new HttpEntity<>(headers);
//
//        // 发送 POST 请求
//        ResponseEntity<String> response = restTemplate.postForEntity("http://localhost:8082/sessions/action/signup", httpEntity, String.class);
//
//        // 处理响应
//        if (response.getStatusCode().is2xxSuccessful()) {
//            String responseBody = response.getBody();
//            // 处理响应体
//        } else {
//            // 处理请求失败的情况
//        }
        return userService.list();
    }
}
